package cn.hadron.aa.dao.impl;
import org.springframework.stereotype.Repository;
import cn.hadron.aa.dao.*;
import cn.hadron.aa.entity.User;
@Repository("userDao")
public class UserDaoImpl extends BaseDaoImpl<User> implements UserDao{
    //构造器，初始化实体类型
	public UserDaoImpl(){
        super(User.class);
    }
	@Override
	public boolean getByName(String username) {
		User u = getSession().createQuery("from User where username=?", User.class)
				.setParameter(0, username).uniqueResult();
		return u!=null;
	}
	@Override
	public User get(String username, String password) {
		String hql = "from User where username=? and password=?";
		User u = getSession().createQuery(hql, User.class).setParameter(0, username)
				.setParameter(1, password).uniqueResult();
		return u;
	}
}
